/**
  \file dawggen.c
  \author Francis Girard
  \date 6 march 2012
  
  Dawg generator stand-alone executable tool.
*/


/*
 *  Copyright (C) 2012, Francis Girard
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/*
 *  Copyright (C) 2011, Jerzy Chalupski
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */


#include "dawggenerator.h"
#include <stdlib.h>

/**
  Main C function.
*/
int main(int argc, char* argv[])
{
  unsigned char bDetailDump = 0;
  int nRetCode = 0;
  
  {
    char** argvCpy = (char**) malloc(sizeof(char*)*argc);
    int nArgcCpy = 0;
    int nArgcOrg = 0;
    
    for ( ; nArgcOrg < argc; nArgcOrg++)
    {
      if (strcmp(argv[nArgcOrg], "-d") == 0 ||
          strcmp(argv[nArgcOrg], "-D") == 0 ||
          strcmp(argv[nArgcOrg], "--detail") == 0)
      {
        bDetailDump = 1;
      }
      else
      {
        argvCpy[nArgcCpy] = argv[nArgcOrg];
        nArgcCpy++;
      }
    }
    
    argv = argvCpy;
    argc = nArgcCpy;
  }
  
  {
    const char* pkcWordListFileName = argv[1];
    const char* pkcEncodedFileName = argv[2];
    int nRetCode = generate_dawg(pkcWordListFileName,
                                 pkcEncodedFileName,
                                 bDetailDump);
  }
  
  return nRetCode;
}


